package com.czk.index;

import com.czk.util.ClientUtil;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;

import java.io.IOException;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/6/13 13:51
 */
public class GetIndex {
    public static void main(String[] args) throws IOException {
        RestHighLevelClient highLevelClient = ClientUtil.getHighLevelClient();
        GetIndexRequest getIndexRequest = new GetIndexRequest("user");
        // 是否存在
        GetIndexResponse getIndexResponse = highLevelClient.indices().get(getIndexRequest, RequestOptions.DEFAULT);
        // 拿到索引配置
        System.out.println("别名=" + getIndexResponse.getAliases());
        System.out.println("分片=" + getIndexResponse.getMappings());
        System.out.println("设置" + getIndexResponse.getSettings());
        highLevelClient.close();
    }
}
